﻿using SaaS.Core.Logger;
using System;
using System.Collections.Generic;
using XCore.Dependency;
using XCore.Timer;

namespace SaaS.Scheduler
{
    public abstract class SchedulerServiceBase : TimeServiceBase
    {
        private readonly SchedulerLogger _schedulerLogger;
        private readonly ErrorLogger _errorLogger;
        public SchedulerServiceBase()
        {
            _schedulerLogger = IocCollection.Resolve<SchedulerLogger>();
            _errorLogger = IocCollection.Resolve<ErrorLogger>();
        }
        public override TimeSpan Time { get; }

        public override string Name { get; }

        public override void Invoke()
        {

        }
        public override void ExcuteError(Exception exception)
        {
            _errorLogger.Log(exception);
            base.ExcuteError(exception);
        }
        public override void ExcuteSuccess(TimeServiceWriteModel model)
        {
            _schedulerLogger.Log(model);
            base.ExcuteSuccess(model);
        }
    }
}
